﻿#region Copyright information
// 
// Copyright © 2005-2013 Yongkee Cho. All rights reserved.
// 
// This code is a part of the Biological Object Library and governed under the terms of the
// GNU Lesser General  Public License (LGPL) version 2.1 which accompanies this distribution.
// For more information on the LGPL, please visit http://bol.codeplex.com/license.
// 
// - Filename: OneSampleTTest.cs
// - Author: Yongkee Cho
// - Email: yongkeecho@gmail.com
// - Date Created: 2012-09-06 11:39 AM
// - Last Modified: 2013-01-25 3:59 PM
// 
#endregion
using System;
using System.Collections.Generic;
using BOL.Maths.Distributions;

namespace BOL.Maths.Statistics.HypothesisTest
{
    public class OneSampleTTest : OneSampleMeanTestBase
    {
        #region Constructors

        public OneSampleTTest(TestType type, double alpha, double mu0, IEnumerable<double> sample)
            : base(type, alpha, mu0, sample)
        {
            Distribution = new StudentsTDistribution(SampleSize - 1);
        }

        public OneSampleTTest(TestType type, double mu0, IEnumerable<double> sample) : this(type, 0.05, mu0, sample) { }

        public OneSampleTTest(double alpha, double mu0, IEnumerable<double> sample) : this(TestType.TwoSided, alpha, mu0, sample) { }

        public OneSampleTTest(double mu0, IEnumerable<double> sample) : this(TestType.TwoSided, 0.05, mu0, sample) { }

        #endregion

        #region Object overriden

        public override string ToString()
        {
            return String.Format("T-Test (T = {0}, p-value = {1:G3}): {2}", TestStatistic, PValue, (IsSignificant) ? "Reject H0" : "Accept H0");
        }

        #endregion
    }
}
